{% load i18n grp_tags %}

<style>
    #user-tools li.user-options-container {
        width: auto;
    }
</style>

<div id="header">
    <div class="branding">&nbsp;</div>
    <!-- Title -->
    <div class="admin-title">{% if grappelli_admin_title %}{{ grappelli_admin_title }}{% else %}{% get_admin_title %}{% endif %}</div>
    {% if user.is_authenticated and user.is_staff %}
        <ul id="user-tools">
            <!-- Student  -->
            {% if perms.sis.change_student or perms.sis.view_student or perms.sis.reports %}
                <li class="user-options-container collapse closed">
                    <a href="javascript://" class="user-options-handler collapse-handler"> Student </a>
                    <ul class="user-options">
                        {% if perms.sis.view_student %}
                            <li><a href="{% url ecwsp.sis.views.photo_flash_card %}">{% trans 'Flashcards' %}</a></li>
                            <li><a href="{% url ecwsp.sis.views.view_student %}">{% trans 'View' %}</a></li>
                        {% endif %}
                        {% if perms.sis.change_student or perms.sis.view_student %}
                            <li><a href="{% url admin:sis_student_changelist %}">{% trans 'Edit' %}</a></li>
                        {% endif %}
                        {% if perms.sis.reports %}
                            <li><a href="{% url ecwsp.sis.views.school_report_builder_view %}">{% trans 'Reports' %}</a></li>
                        {% endif %}
                    </ul>
                </li>
            {% endif %}
            <!-- Attendance  -->
            {% if perms.sis.reports or perms.sis.change_studentattendance or perms.sis.take_studentattendance %}
                <li class="user-options-container collapse closed">
                    <a href="javascript://" class="user-options-handler collapse-handler"> {% trans 'Attendance' %} </a>
                    <ul class="user-options">
                        {% if perms.sis.take_studentattendance %}
                            <li><a href="{% url ecwsp.sis.views.teacher_attendance %}">{% trans 'Take Homeroom Attendance' %}</a>
                        {% endif %}
                        {% if perms.sis.change_studentattendance %}
                            <li><a href="{% url admin:sis_studentattendance_changelist %}">{% trans 'Edit' %}</a></li>
                        {% endif %}
                        {% if perms.studentattendance.reports %}
                            <li><a href="{% url ecwsp.sis.views.attendance_report %}">{% trans 'Reports' %}</a></li>
                        {% endif %}
                    </ul>
                </li>
            {% endif %}
            <!-- Discipline  -->
            {% if perms.sis.change_studentdiscipline %}
                <li class="user-options-container collapse closed">
                    <a href="javascript://" class="user-options-handler collapse-handler"> {% trans 'Discipline' %} </a>
                    <ul class="user-options">
                        {% if perms.sis.change_studentdiscipline %}
                            <li><a href="{% url ecwsp.sis.views.view_discipline %}">{% trans 'View' %}</a>
                        {% endif %}
                        {% if perms.sis.change_studentdiscipline %}
                            <li><a href="{% url admin:sis_studentdiscipline_changelist %}">{% trans 'Edit' %}</a></li>
                        {% endif %}
                        {% if perms.sis.reports %}
                            <li><a href="{% url ecwsp.sis.views.discipline_report_view %}">{% trans 'Reports' %}</a></li>
                        {% endif %}
                    </ul>
                </li>
            {% endif %}
            <!-- Grades  -->
            {% if 'ecwsp.schedule' in settings.INSTALLED_APPS %} {% if perms.schedule.change_course or perms.schedule.change_own_grade or perms.sis.reports %}
                <li class="user-options-container collapse closed">
                    <a href="javascript://" class="user-options-handler collapse-handler"> Grades </a>
                    <ul class="user-options">
                        {% if perms.schedule.change_course %}
                            <li><a href="{% url admin:schedule_course_changelist %}">{% trans 'Edit Grades/Courses' %}</a></li>
                        {% endif %}
                        {% if perms.schedule.change_own_grade %}
                            <li><a href="{% url ecwsp.schedule.views.teacher_grade %}">{% trans 'Submit Grades' %}</a>
                        {% endif %}
                        {% if perms.sis.reports %}
                            <li><a href="{% url ecwsp.sis.views.grade_report %}">{% trans 'Reports' %}</a></li>
                            <li><a href="{% url ecwsp.schedule.views.grade_analytics %}">{% trans 'Analytics' %}</a></li>
                        {% endif %}
                    </ul>
                </li>
            {% endif %}{% endif %}
            <!-- Admissions  -->
            {% if perms.admissions.change_applicant and 'ecwsp.admissions' in settings.INSTALLED_APPS %}
                <li class="user-options-container collapse closed">
                    <a href="javascript://" class="user-options-handler collapse-handler"> Admissions </a>
                    <ul class="user-options">
                        {% if perms.admissions.change_applicant %}
                            <li><a href="{% url admin:admissions_applicant_changelist %}">{% trans 'Applicants' %}</a></li>
                        {% endif %}
                        {% if perms.admissions.change_applicant %}
                            <li><a href="{% url ecwsp.admissions.views.reports %}">{% trans 'Reports' %}</a></li>
                        {% endif %}
                    </ul>
                </li>
            {% endif %}
            <!-- Alumni -->
            {% if perms.alumni.change_alumni and 'ecwsp.alumni' in settings.INSTALLED_APPS %}
                <li class="user-options-container collapse closed">
                    <a href="javascript://" class="user-options-handler collapse-handler"> Alumni </a>
                    <ul class="user-options">
                        <li><a href="{% url admin:app_list 'alumni'%}">{% trans 'Alumni Admin' %}</a></li>
                        <li><a href="{% url admin:alumni_alumni_changelist %}">{% trans 'Alumnus' %}</a></li>
                    </ul>
                </li>
            {% endif %}
            <!-- CWSP -->
            {% if 'ecwsp.work_study' in settings.INSTALLED_APPS %} {% if perms.work_study.change_studentworker or perms.work_study.view_studentworker or perm.work_study.reports %}
                <li class="user-options-container collapse closed">
                    <a href="javascript://" class="user-options-handler collapse-handler"> CWSP </a>
                    <ul class="user-options">
                        {% if perms.work_study.change_studentworker or perms.work_study.view_studentworker %}
                            <li><a href="{% url admin:work_study_studentworker_changelist %}">{% trans 'Edit Student Worker' %}</a></li>
                        {% endif %}
                        {% if perms.sis.reports %}
                            <li><a href="{% url ecwsp.work_study.views.report_builder_view %}">{% trans 'Reports' %}</a></li>
                        {% endif %}
                    </ul>
                </li>
            {% endif %}{% endif %}
            <!-- OMR -->
            {% if perms.omr.change_test and 'ecwsp.omr' in settings.INSTALLED_APPS %}
                <li class="user-options-container collapse closed">
                    <a href="javascript://" class="user-options-handler collapse-handler"> OMR </a>
                    <ul class="user-options">
                        {% if perms.omr.change_test %}
                            <li><a href="{% url admin:app_list 'omr'%}">{% trans 'OMR Admin' %}</a></li>
                            <li><a href="{% url ecwsp.omr.views.my_tests %}"> {% trans 'My Tests' %}
                        {% endif %}
                    </ul>
                </li>
            {% endif %}
            <!-- Administration -->
            {% if perms.sis.reports or perms.administration.change_configuration %}
                <li class="user-options-container collapse closed">
                    <a href="javascript://" class="user-options-handler collapse-handler"> Admin </a>
                    <ul class="user-options">
                        {% if perms.sis.reports %}
                            <li><a href="{% url ecwsp.sis.views.import_everything %}">{% trans 'School import' %}</a></li>
                        {% endif %}
                        {% if perms.administration.change_configuration %}
                            <li><a href="{% url admin:administration_configuration_changelist %}">{% trans 'Configuration' %}</a></li>
                        {% endif %}
                    </ul>
                </li>
            {% endif %}
            <!-- Username -->
            <li class="user-options-container collapse closed">
                <a href="javascript://" class="user-options-handler collapse-handler">{% firstof user.first_name user.username %}</a>
                <ul class="user-options">
                    <!--SWORD: added preferences -->
                    <li><a href="/sis/preferences">{% trans 'Preferences' %}</a>
                    <!-- Change Password -->
                    {% url admin:password_change as password_change_url %}
                    {% if password_change_url %}
                        <li><a href="{{ password_change_url }}">
                    {% else %}
                        <li><a href="{{ root_path }}password_change/">
                    {% endif %}
                    {% trans 'Change password' %}</a></li>
                    <!-- Logout -->
                    {% url admin:logout as logout_url %}
                    {% if logout_url %}
                        <li><a href="{{ logout_url }}">
                    {% else %}
                        <li><a href="{{ root_path }}logout/">
                    {% endif %}
                    {% trans 'Log out' %}</a></li>
                </ul>
            </li>
            <!-- Userlinks -->
            {% block userlinks %}
                <!-- JS tests -->
                {% url test-index as testindexurl %}
                {% if testindexurl %}
                    <li><a href="{{ testindexurl }}">{% trans 'Tests' %}</a></li>
                {% endif %}
                <!-- Documentation -->
                {% url django-admindocs-docroot as docsroot %}
                {% if docsroot %}
                    <li><a href="{{ docsroot }}">{% trans 'Documentation' %}</a></li>
                {% endif %}
            {% endblock %}
        </ul>
    {% endif %}
    {% block nav-global %}
    {% endblock %}
</div>

<script type="text/javascript" charset="utf-8">
    (function($) {
        $(document).ready(function() {
            $("div#header .collapse").grp_collapsible();
        });
    })(django.jQuery);
</script>